package com.link.base.tencent.corpwx.externalcontact.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import com.link.core.cllog.LCLogger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import com.link.base.tencent.corpwx.externalcontact.model.GroupChat;
import com.link.base.tencent.corpwx.externalcontact.service.GroupChatService;
import com.link.core.basic.controller.BasicController;
import com.link.core.basic.service.BasicService;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * 客户群管理 
 *
 * @author 欧阳振强
 * @date 2020-03-18 15:08:43.0
 */
@Controller
@RequestMapping("/link/corpwx/groupChat")
public class GroupChatController extends BasicController<GroupChat> {

    @Resource
    private GroupChatService groupChatService;

    @Override
    public BasicService<GroupChat> getBasicService() throws Exception {
        return groupChatService;
    }

    /**
     * 同步企业微信客户群聊信息到CRM
     * 
     * @author 欧阳振强
     * @date 2020/03/18
     */
    @GetMapping(value = "/syncGroupChatFromWx", name = "同步企业微信客户群聊信息到CRM")
    @ResponseBody
    public Map<String, Object> syncGroupChatFromWx(HttpSession session, HttpServletRequest request) {
        Map<String, Object> result = new HashMap<String, Object>(2);
        try {
            groupChatService.syncGroupChatFromWx();
            result.put("success", true);
        } catch (Exception e) {
            LCLogger.withException(e);
            result.put("success", false);
            result.put("result", e.toString());
        }
        return result;
    }

}
